<?php

include_once ('bn_path.php');

class bn_timer
{
    public $interval = '5000';
    public $run_once = false;
    public $js_func = '';
    protected static $instance;

    public static function getInstance()
    {
        if (!isset(self::$instance))
        {
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function run()
    {
        $out = '';
        if ($this->run_once)
            $out = 'window.setTimeout(function() {' . $this->jsfunc . '},' . $this->
                interval . ');';
        else
            $out = 'window.setInterval(function() {' . $this->jsfunc . '},' . $this->
                interval . ');';
        return $out;
    }
}

?>